var mod = angular.module('app.config', []);

var SESSION_SERVER = 'session.server';

mod.config(['ApiProvider', 'SocketProvider', function (ApiProvider, SocketProvider) {
    var apiUrl = CONFIG.API_URL;
    var websocketUrl = CONFIG.WEBSOCKET_URL;

    try {
        var _JSON$parse = JSON.parse(localStorage.getItem(SESSION_SERVER));

        apiUrl = _JSON$parse.apiUrl;
        websocketUrl = _JSON$parse.websocketUrl;
        settings = _JSON$parse.settings;


        if (settings) {
            delete ApiProvider.options.official;

            Object.assign(ApiProvider.options, settings);
        }
    } catch (err) {}

    ApiProvider.options.historyUrl = CONFIG.HISTORY_URL;
    ApiProvider.options.apiUrl = apiUrl;
    SocketProvider.options.websocketUrl = websocketUrl;
}]);

mod.run(['$rootScope', 'LocalStorage', function ($rootScope, LocalStorage) {
    var prefix = CONFIG.PREFIX;

    try {
        var _JSON$parse2 = JSON.parse(localStorage.getItem(SESSION_SERVER));

        prefix = _JSON$parse2.prefix;
    } catch (err) {}

    $rootScope.ptr = CONFIG.IS_PTR;
    $rootScope.debug = CONFIG.DEBUG;
    LocalStorage.prefix = prefix;
}]);
